package com.example.composite;

import com.example.composite.Impi.IndividualEmployeeImpi;
import com.example.composite.Impi.ManagerImpi;

/**
 * 组合模式，相当于一棵树，每个分支可能又有不同的发分支
 */
public class Test {
    public static void main(String[] args) {
        IndividualEmployeeImpi i1 = new IndividualEmployeeImpi("1号", "普通员工");
        IndividualEmployeeImpi i2 = new IndividualEmployeeImpi("2号", "普通员工");
        IndividualEmployeeImpi i3 = new IndividualEmployeeImpi("3号", "普通员工");
        ManagerImpi managerImpi1 = new ManagerImpi("5号", "经理下属");
        IndividualEmployeeImpi impi = new IndividualEmployeeImpi("需要被找出的员工", "普通员工");

        managerImpi1.add(impi);

        ManagerImpi managerImpi = new ManagerImpi("4号", "经理");
        managerImpi.add(i1);
        managerImpi.add(i2);
        managerImpi.add(i3);
        managerImpi.add(managerImpi1);

        managerImpi.findEmployeeByBFS(impi).showDetails();

        managerImpi.findEmployeeByDFS(impi).showDetails();
    }
}
